package com.yy.wga.goods.service.common.enums;

import com.yy.wga.goods.service.api.bo.CategoryBO;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;

@AllArgsConstructor
@Getter
public enum ECategory {

    ALL(0, "全部", null),
    FOOD_FRESH(1, "食品生鲜", new CategoryBO(new BigInteger("11099070301657575487"), Arrays.asList(7339, 502043, 7419, 6625), "食品生鲜")),
    CLOTHING_SHOE_BAG(2, "服饰鞋包", new CategoryBO(new BigInteger("16579416177373560313"), Arrays.asList(6033, 1653, 6831, 7378, 6932), "服饰鞋包")),
    PROTECT_YOUR_BEAUTY_MAKEUP(3, "个护美妆", new CategoryBO(new BigInteger("17007902228422672609"), Arrays.asList(1001, 6870), "个护美妆")),
    BOOKS(4, "图书", new CategoryBO(new BigInteger("12377324634086192020"), Arrays.asList(135835), "图书")),
    HOUSEHOLD_DAY(5, "家清日用", new CategoryBO(new BigInteger("8261345894708739273"), Arrays.asList(1142, 1421, 1453, 1208, 6153, 6472, 1069, 1247), "家清日用")),
    OTHER(6, "其他", new CategoryBO(new BigInteger("12379480883574690382"), Arrays.asList(530004, 376707, 1804, 442005, 1701, 381003, 128209, 6263, 377078, 378228, 530032, 7363, 378136, 429008, 6706), "其他")),
    ;

    private Integer type;
    private String name;
    private CategoryBO category;

    public static Map<String, Integer> getCategoryTypeNameMap() {
        Map<String, Integer> map = new LinkedHashMap<>();
        for (ECategory category : values()) {
            map.put(category.getName(), category.getType());
        }
        return map;
    }

    public static CategoryBO parseCategory(Integer categoryTypeN) {
        return Arrays.stream(values()).filter(e -> e.getType().equals(categoryTypeN)).findFirst().orElse(ALL).getCategory();
    }
}
